home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / General / MM3Tp.sea Folder / Made by Marksman / Sources / u / eventsMM_Demo.p < prev    next >
Text File  |  1994-01-16  |  6KB  |  256 lines

  1. unit UeventsMM_Demo;
  2. {  Copyright © 1994 George R. Cossey }
  3. {  eventsMM_Demo                                    Additional event handler routines
  4.  
  5.     File name:  eventsMM_Demo  
  6.     Function:  This module contains the extra event handler routines
  7.      These routines allow us to override events in the main loop,
  8.      and to handle unique events.
  9.     History: 1/16/94 Original by George Cossey
  10.  
  11.    }
  12.  
  13. interface
  14.  
  15.     uses
  16.         Printing, Folders, Sound,mmCommonMM_Demo,CommonMM_Demo;
  17.  
  18. { ======================================================= }
  19. { ======================================================= }
  20.  
  21. { Handle the OS event }
  22. procedure DoOSEvent(var myEvent:EventRecord);
  23.  
  24. { Handle special key combinations }
  25. function HandleKey(var myEvent:EventRecord):Boolean;
  26.  
  27. { Special disk inserted handling }
  28. function HandleDisk(var myEvent:EventRecord):Boolean;
  29.  
  30. { Handle our special Zooms }
  31. procedure U_DoZoom(OldRect:Rect;whichWindow:WindowPtr);
  32.  
  33. { Handle our special Moves }
  34. procedure U_Moved(OldRect:Rect;whichWindow:WindowPtr);
  35.  
  36. { Handle our special go aways }
  37. procedure U_GoAway(whichWindow:WindowPtr);
  38.  
  39. { Handle our special hits in our windows }
  40. procedure U_InContent(var myEvent:EventRecord;whichWindow:WindowPtr);
  41.  
  42. { Handle our special updates }
  43. procedure U_Update(whichWindow:WindowPtr);
  44.  
  45. { Handle our special activates }
  46. procedure U_Activate(whichWindow:WindowPtr;Do_An_Activate:Boolean);
  47.  
  48. { Handle our special activates }
  49. procedure U_EnableMenus;
  50.  
  51. { Let us into the main loop }
  52. procedure ApplLoopMM_Demo;
  53.  
  54. { Filter events from the main loop }
  55. procedure ApplEventMM_Demo(var DoIt:Boolean;var myEvent:EventRecord);
  56.  
  57. { Handle our special user events }
  58. procedure Handle_UserEvent(TheUserEvent:UserEventPRec);
  59.  
  60. { ======================================================= }
  61. { ======================================================= }
  62.  
  63. implementation
  64.  
  65. { ======================================================= }
  66. { ======================================================= }
  67.  
  68. { Routine: DoOSEvent }
  69. { Purpose: Handle DoOSEvents }
  70.  
  71. procedure DoOSEvent(var myEvent:EventRecord);
  72.  
  73.  
  74. begin
  75. if (BSR(BAND(myEvent.message, osEvtMessageMask), 24) = suspendResumeMessage) then
  76.     begin
  77.     if (BAND(myEvent.message,resumeFlag) = 0) then    { Suspend }
  78.         InTheForeground := FALSE
  79.     else
  80.         InTheForeground := TRUE;
  81.     end;
  82. end;
  83.  
  84. { ======================================================= }
  85.  
  86. { Routine: HandleKey }
  87. { Purpose: Allow us to filter key strokes and special key combinations }
  88. { Return TRUE if we let the main loop handle the key stroke }
  89.  
  90. function HandleKey(var myEvent:EventRecord):Boolean;
  91. var
  92.         charCode:integer;                            { Key code }
  93.         ch:char;                                    { Key pressed in Ascii }
  94.         CmdKeyPressed:Boolean;                        { Command key pressed }
  95.         OptionKeyPressed:Boolean;                    { Option key pressed }
  96.         ShiftKeyPressed:Boolean;                    { Shift key pressed }
  97.         theHandleKey:Boolean;                        { value to return }
  98.  
  99.  
  100. begin
  101. theHandleKey := TRUE;                            { Let the main loop handle it }
  102.  
  103. charCode := BAND(myEvent.message,charCodeMask);        { Get the character }
  104. ch := char(charCode);                            { Change it to ASCII }
  105.  
  106. CmdKeyPressed := (BAND(myEvent.modifiers,cmdKey) <> 0);        { See if Command key is down }
  107. OptionKeyPressed := (BAND(myEvent.modifiers,optionKey) <> 0);    { See if Option key is down }
  108. ShiftKeyPressed := (BAND(myEvent.modifiers,shiftKey) <> 0);    { See if Shift key is down }
  109.  
  110. { Add your code here }
  111.  
  112. HandleKey := theHandleKey;                        { Return if we let main routine handle it }
  113. end;
  114.  
  115. { ======================================================= }
  116.  
  117. { Routine: HandleDisk }
  118. { Purpose: Allow us to handle disk inserted events specially }
  119. { Return TRUE if we let the main loop handle the key stroke }
  120.  
  121. function HandleDisk(var myEvent:EventRecord):Boolean;
  122. var
  123.     theHandleDisk:Boolean;                            { value to return }
  124.  
  125.  
  126. begin
  127. theHandleDisk := TRUE;                                { Let the main loop handle it }
  128. HandleDisk := theHandleDisk;                        { Return if we let main routine handle it }
  129. end;
  130.  
  131. { ======================================================= }
  132.  
  133. { Routine: U_DoZoom }
  134. { Purpose: Allow us in to handle it }
  135.  
  136. procedure U_DoZoom(OldRect:Rect;whichWindow:WindowPtr);
  137.  
  138.  
  139. begin
  140. end;
  141.  
  142. { ======================================================= }
  143.  
  144. { Routine: U_Moved }
  145. { Purpose: Allow us in to handle it }
  146.  
  147. procedure U_Moved(OldRect:Rect;whichWindow:WindowPtr);
  148.  
  149.  
  150. begin
  151. end;
  152.  
  153.  
  154. { ======================================================= }
  155.  
  156. { Routine: U_GoAway }
  157. { Purpose: Allow us in to handle it }
  158.  
  159. procedure U_GoAway(whichWindow:WindowPtr);
  160.  
  161.  
  162. begin
  163. end;
  164.  
  165. { ======================================================= }
  166.  
  167. { Routine: U_InContent }
  168. { Purpose: Allow us in to handle it }
  169.  
  170. procedure U_InContent(var myEvent:EventRecord;whichWindow:WindowPtr);
  171.  
  172.  
  173. begin
  174. end;
  175.  
  176. { ======================================================= }
  177.  
  178. { Routine: U_Update }
  179. { Purpose: Allow us in to handle it }
  180.  
  181. procedure U_Update(whichWindow:WindowPtr);
  182.  
  183.  
  184. begin
  185. end;
  186.  
  187. { ======================================================= }
  188.  
  189. { Routine: U_Activate }
  190. { Purpose: Allow us in to handle it }
  191.  
  192. procedure U_Activate(whichWindow:WindowPtr;Do_An_Activate:Boolean);
  193.  
  194.  
  195. begin
  196. end;
  197.  
  198. { ======================================================= }
  199.  
  200. { Routine: U_EnableMenus }
  201. { Purpose: Allow us in to handle it }
  202.  
  203. procedure U_EnableMenus;
  204.  
  205.  
  206. begin
  207. end;
  208.  
  209. { ======================================================= }
  210.  
  211. { Routine: ApplLoopMM_Demo }
  212. { Purpose: At the top of the main loop, called each time thru the main }
  213. { loop.  This is very often if WNE was false. }
  214.  
  215. procedure ApplLoopMM_Demo;
  216.  
  217.  
  218. begin
  219. end;
  220.  
  221. { ======================================================= }
  222.  
  223. { Routine: ApplEventMM_Demo }
  224. { Purpose: Allow us to filter all events before the main loop handles them }
  225. { Set  DoIt  to TRUE to let the main loop handle the event. }
  226.  
  227. procedure ApplEventMM_Demo(var DoIt:Boolean;var myEvent:EventRecord);
  228.  
  229.  
  230. begin
  231. DoIt := TRUE;                                        { Let the main loop handle it }
  232.  
  233. if (WNE) then                                        { Check for mouse in cursor area available }
  234.     begin
  235.     { Check cursor region for possible cursor shape change, cursorRgn }
  236.     end;
  237.  
  238. if (myEvent.what = 0) then                         { Handle a NULL event}
  239.     DoIt := FALSE;                                    { Tell the main loop to skip it}
  240. end;
  241.  
  242. { ======================================================= }
  243.  
  244. { Routine: Handle_UserEvent }
  245. { Purpose: Handle our special user events }
  246.  
  247. procedure Handle_UserEvent(TheUserEvent:UserEventPRec);
  248.  
  249.  
  250. begin
  251. end;
  252.  
  253. { ======================================================= }
  254. { ======================================================= }
  255. end.
  256.